package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UsdtUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// usdt--修改
func NewUsdtUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsdtUpdateLogic {
	return &UsdtUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UsdtUpdateLogic) UsdtUpdate(req *types.UsdtUpdateRequest) (resp *types.UsdtUpdateResponse, err error) {
	rpcReq := rpc.UsdtUpdateRequest{
		Id:       req.Id,
		Name:     req.Name,
		UsdtType: req.UsdtType,
		QrCode:   req.QrCode,
		Address:  req.Address,
		Sort:     uint32(req.Sort),
		Status:   req.Status,
	}

	rpcResp, err := l.svcCtx.AssetsRpc.TenantChannel.UsdtUpdate(l.ctx, &rpcReq)
	if err != nil {
		return nil, err
	}

	return &types.UsdtUpdateResponse{
		CommonResp: types.CommonResp{
			Code:    rpcResp.CommonResp.Code,
			Message: rpcResp.CommonResp.Message,
		},
	}, nil
}
